home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Gfx / Edit / TSMorph / src / ControlWindow.c < prev    next >
C/C++ Source or Header  |  1995-02-06  |  20KB  |  654 lines

  1. // TSMorph - Amiga Morphing program
  2. // Copyright (C) © 1993  Topicsave Limited
  3.  
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; either version 2 of the License, or
  7. // any later version.
  8.  
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. // GNU General Public License for more details.
  13.  
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program; if not, write to the Free Software
  16. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. // mpaddock@cix.compulink.co.uk
  19.  
  20. // Include precompiled headers if not already included
  21. #ifndef TSMORPH_H
  22. #include "TSMorph.h"
  23. #endif
  24.  
  25. /* Gadgets in the control window */
  26. extern struct ExtGadget OneGadget = {
  27.     &TwoGadget,
  28.     0,0,
  29.     IMAGE_WIDTH,IMAGE_HEIGHT,
  30.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  31.     GACT_IMMEDIATE,
  32.     GTYP_BOOLGADGET,
  33.     &One_im,
  34.     &One_imx,
  35.     NULL,
  36.     0,
  37.     NULL,
  38.     ONEGADGET,
  39.     NULL,
  40.     GMORE_GADGETHELP
  41. };
  42. extern struct ExtGadget TwoGadget = {
  43.     &RelGadget,
  44.     0,0,
  45.     IMAGE_WIDTH,IMAGE_HEIGHT,
  46.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  47.     GACT_IMMEDIATE,
  48.     GTYP_BOOLGADGET,
  49.     &Two_im,
  50.     &Two_imx,
  51.     NULL,
  52.     0,
  53.     NULL,
  54.     TWOGADGET,
  55.     NULL,
  56.     GMORE_GADGETHELP
  57. };
  58. extern struct ExtGadget RelGadget = {
  59.     &MyAddGadget,
  60.     0,0,
  61.     IMAGE_WIDTH,IMAGE_HEIGHT,
  62.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  63.     GACT_IMMEDIATE,
  64.     GTYP_BOOLGADGET,
  65.     &Rel_im,
  66.     &Rel_imx,
  67.     NULL,
  68.     0,
  69.     NULL,
  70.     RELGADGET,
  71.     NULL,
  72.     GMORE_GADGETHELP
  73. };
  74. extern struct ExtGadget MyAddGadget = {    // Note not AddGadget as this is a function!
  75.     &DelGadget,
  76.     0,0,
  77.     IMAGE_WIDTH,IMAGE_HEIGHT,
  78.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  79.     GACT_IMMEDIATE,
  80.     GTYP_BOOLGADGET,
  81.     &Add_im,
  82.     &Add_imx,
  83.     NULL,
  84.     0,
  85.     NULL,
  86.     ADDGADGET,
  87.     NULL,
  88.     GMORE_GADGETHELP
  89. };
  90. extern struct ExtGadget DelGadget = {
  91.     &LinkGadget,
  92.     0,0,
  93.     IMAGE_WIDTH,IMAGE_HEIGHT,
  94.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  95.     GACT_IMMEDIATE,
  96.     GTYP_BOOLGADGET,
  97.     &Del_im,
  98.     &Del_imx,
  99.     NULL,
  100.     0,
  101.     NULL,
  102.     DELGADGET,
  103.     NULL,
  104.     GMORE_GADGETHELP
  105. };
  106. extern struct ExtGadget LinkGadget = {
  107.     &UnlinkGadget,
  108.     0,0,
  109.     IMAGE_WIDTH,IMAGE_HEIGHT,
  110.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  111.     GACT_IMMEDIATE,
  112.     GTYP_BOOLGADGET,
  113.     &Link_im,
  114.     &Link_imx,
  115.     NULL,
  116.     0,
  117.     NULL,
  118.     LINKGADGET,
  119.     NULL,
  120.     GMORE_GADGETHELP
  121. };
  122. extern struct ExtGadget UnlinkGadget = {
  123.     &NoneGadget,
  124.     0,0,
  125.     IMAGE_WIDTH,IMAGE_HEIGHT,
  126.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  127.     GACT_IMMEDIATE,
  128.     GTYP_BOOLGADGET,
  129.     &Unlink_im,
  130.     &Unlink_imx,
  131.     NULL,
  132.     0,
  133.     NULL,
  134.     UNLINKGADGET,
  135.     NULL,
  136.     GMORE_GADGETHELP
  137. };
  138. extern struct ExtGadget NoneGadget = {
  139.     &stGadget,
  140.     0,0,
  141.     IMAGE_WIDTH,IMAGE_HEIGHT,
  142.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_SELECTED|GFLG_EXTENDED,
  143.     GACT_IMMEDIATE,
  144.     GTYP_BOOLGADGET,
  145.     &None_im,
  146.     &None_imx,
  147.     NULL,
  148.     0,
  149.     NULL,
  150.     NONEGADGET,
  151.     NULL,
  152.     GMORE_GADGETHELP
  153. };
  154. extern struct ExtGadget stGadget = {
  155.     &prevGadget,
  156.     0,0,
  157.     AIMAGE,AIMAGE,
  158.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  159.     GACT_RELVERIFY,
  160.     GTYP_BOOLGADGET,
  161.     &st_im,
  162.     &st_imx,
  163.     NULL,
  164.     0,
  165.     NULL,
  166.     STGADGET,
  167.     NULL,
  168.     GMORE_GADGETHELP
  169. };
  170. extern struct ExtGadget prevGadget = {
  171.     &gotoGadget,
  172.     0,0,
  173.     AIMAGE,AIMAGE,
  174.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  175.     GACT_RELVERIFY,
  176.     GTYP_BOOLGADGET,
  177.     &prev_im,
  178.     &prev_imx,
  179.     NULL,
  180.     0,
  181.     NULL,
  182.     PREVGADGET,
  183.     NULL,
  184.     GMORE_GADGETHELP
  185. };
  186. extern struct ExtGadget gotoGadget = {
  187.     &nextGadget,
  188.     0,0,
  189.     AIMAGE+1,AIMAGE,
  190.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  191.     GACT_RELVERIFY,
  192.     GTYP_BOOLGADGET,
  193.     &goto_im,
  194.     &goto_imx,
  195.     NULL,
  196.     0,
  197.     NULL,
  198.     GOTOGADGET,
  199.     NULL,
  200.     GMORE_GADGETHELP
  201. };
  202. extern struct ExtGadget nextGadget = {
  203.     &lastGadget,
  204.     0,0,
  205.     AIMAGE,AIMAGE,
  206.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  207.     GACT_RELVERIFY,
  208.     GTYP_BOOLGADGET,
  209.     &next_im,
  210.     &next_imx,
  211.     NULL,
  212.     0,
  213.     NULL,
  214.     NEXTGADGET,
  215.     NULL,
  216.     GMORE_GADGETHELP
  217. };
  218. extern struct ExtGadget lastGadget = {
  219.     NULL,
  220.     0,0,
  221.     AIMAGE,AIMAGE,
  222.     GFLG_GADGHIMAGE|GFLG_GADGIMAGE|GFLG_EXTENDED,
  223.     GACT_RELVERIFY,
  224.     GTYP_BOOLGADGET,
  225.     &last_im,
  226.     &last_imx,
  227.     NULL,
  228.     0,
  229.     NULL,
  230.     LASTGADGET,
  231.     NULL,
  232.     GMORE_GADGETHELP
  233. };
  234.  
  235. /* Menu for the Control Window - comments on the right are the array index */
  236. extern struct NewMenu MyNewMenu[] = {    // There must be an easier way!
  237.     { NM_TITLE, NULL,NULL,0,0,NULL },            // 0
  238.         { NM_ITEM,NULL,NULL,0,0,0 },            // 1
  239.         { NM_ITEM,NULL,NULL,0,0,0 },    // 2
  240.        { NM_ITEM,NM_BARLABEL,NULL,0,0,NULL },        // 3
  241.        { NM_ITEM,NULL,NULL,0,0,0},                    // 4
  242.        { NM_ITEM,NULL,NULL,0,0,0},            // 5
  243.        { NM_ITEM,NM_BARLABEL,NULL,0,0,NULL },        // 6
  244.         { NM_ITEM,NULL,NULL,0,0,0 },            // 7
  245.        { NM_ITEM,NM_BARLABEL,NULL,0,0,NULL },        // 8
  246.         { NM_ITEM,NULL,NULL,0,0,0 },        // 9
  247.        { NM_ITEM,NM_BARLABEL,NULL,0,0,NULL },        // 10
  248.         { NM_ITEM,NULL,NULL,0,0,0 },                    // 11
  249.        { NM_ITEM,NM_BARLABEL,NULL,0,0,NULL },        // 12
  250.         { NM_ITEM,NULL,NULL,0,0,NULL },    // 13
  251.     { NM_TITLE, NULL,0,0,0,NULL},                    // 14
  252.         { NM_ITEM,NULL,NULL,0,0,0 },        // 15
  253.         { NM_ITEM,NULL,NULL,0,0,0 },        // 16
  254.        { NM_ITEM,NULL,NULL,0,0,NULL },            // 17
  255.             { NM_SUB,NULL,NULL,0,0,0 },                // 18
  256.             { NM_SUB,NULL,NULL,0,0,0 },            // 19
  257.             { NM_SUB,NULL,NULL,0,0,0 },            // 20
  258.             { NM_SUB,NULL,NULL,0,0,0 },                // 21
  259.             { NM_SUB,NULL,NULL,0,0,0 },                // 22
  260.         { NM_ITEM,NULL,0,0,0,NULL },                                        // 23
  261.             { NM_SUB, NULL,NULL,CHECKIT,~1,NULL },                    // 24
  262.             { NM_SUB, NULL,NULL,CHECKIT,~2,NULL },                    // 25
  263.             { NM_SUB, NULL,NULL,CHECKIT,~4,NULL },                    // 26
  264.             { NM_SUB, NULL,     NULL,CHECKIT,~8,NULL },                    // 27
  265.             { NM_SUB, NULL,  NULL,CHECKIT,~16,NULL },                    // 28
  266.             { NM_SUB, NULL,    NULL,CHECKIT,~32,NULL },                    // 29
  267.             { NM_SUB, NULL,  NULL,CHECKIT,~64,NULL },                    // 30
  268.             { NM_SUB, NULL,    NULL,CHECKIT|CHECKED,~128,NULL },        // 31
  269.     { NM_TITLE, NULL,0,0,0,NULL },                                    //    32
  270.         { NM_ITEM,NULL,NULL, CHECKIT|MENUTOGGLE,0,NULL },            // 33
  271.         { NM_ITEM,NULL,NULL, CHECKIT|MENUTOGGLE,0,NULL },            // 34
  272.         { NM_ITEM,NULL,NULL, CHECKIT|MENUTOGGLE,0,NULL },            //             35
  273.         { NM_ITEM,NULL,NULL,0,NULL},                                    //                36
  274.             { NM_SUB, NULL,NULL,CHECKIT,~1,NULL },                //                37
  275.             { NM_SUB, NULL,NULL,CHECKIT,~2,NULL },            //                38
  276.             { NM_SUB, NULL,NULL,CHECKIT,~4,NULL },        //                39
  277.             { NM_SUB, NULL,NULL,CHECKIT,~8,NULL },                        //                40
  278.             { NM_SUB, NULL,NULL,CHECKIT,~16,NULL },                        //                41
  279.         { NM_ITEM,NULL,NULL,0,NULL},                        //                42
  280.         { NM_ITEM,NULL,NULL,0,NULL},                            //                43
  281.         { NM_ITEM,NULL,NULL,0,NULL},                            //                44
  282.         { NM_ITEM,NULL,NULL,0,NULL},                        //                45
  283.        { NM_ITEM,NM_BARLABEL,NULL,0,0,NULL },                                //             46
  284.        { NM_ITEM,NULL,NULL,CHECKIT|MENUTOGGLE,NULL},//            47
  285.        { NM_ITEM,NULL,NULL,CHECKIT|MENUTOGGLE,NULL},    //                48
  286.         { NM_ITEM,NULL, NULL, 0, NULL },                    //             49
  287.        { NM_ITEM,NULL, NULL, 0, NULL },                        //             50
  288.        { NM_ITEM,NULL, NULL, 0, NULL },                //             51
  289.        { NM_ITEM,NM_BARLABEL,NULL,0,0,NULL },                                //             52
  290.         { NM_ITEM,NULL,NULL, CHECKIT|MENUTOGGLE,NULL },//        53
  291.        { NM_ITEM,NULL,NULL,0,NULL},                                        //                54
  292.        { NM_ITEM,NULL,NULL,0,NULL},                                        //                55
  293.        { NM_ITEM,NULL,NULL,0,NULL},                            //                56
  294.        { NM_ITEM,NULL,NULL,0,NULL},                            //                57
  295.        { NM_ITEM,NULL,NULL,0,NULL},                            //                58
  296.        { NM_ITEM,NULL,NULL,0,NULL},                                    //                59
  297.        { NM_ITEM,NULL,NULL,0,NULL},                                        //                60
  298.             { NM_SUB, NULL,NULL,CHECKIT|MENUTOGGLE,NULL },                    //                61
  299.             { NM_SUB, NULL,NULL,CHECKIT|MENUTOGGLE,NULL },    //                62
  300.             { NM_SUB, NULL,NULL,CHECKIT|MENUTOGGLE,NULL },                //                63
  301.             { NM_SUB, NULL,NULL,CHECKIT|MENUTOGGLE,NULL },//                64
  302.             { NM_SUB, NULL,NULL,CHECKIT|MENUTOGGLE,NULL },//                65
  303.        { NM_ITEM,NULL, NULL, 0, NULL },                            //             66
  304.             { NM_SUB, NULL,NULL,CHECKIT,~1,NULL },                    //                67
  305.             { NM_SUB, NULL,NULL,CHECKIT,~2,NULL },                    //                68
  306.             { NM_SUB, NULL,NULL,CHECKIT,~4,NULL },        //                69
  307.             { NM_SUB, NULL,NULL,CHECKIT,~8,NULL },            //                70
  308.             { NM_SUB, NULL,NULL,CHECKIT,~16,NULL },    //            71
  309.             { NM_SUB, NULL,NULL,CHECKIT,~32,NULL },                //                72
  310.             { NM_SUB, NULL,NULL,CHECKIT,~64,NULL },    //                73
  311.             { NM_SUB, NULL,NULL,CHECKIT,~128,NULL },                //                74
  312.             { NM_SUB, NULL,NULL,CHECKIT,~256,NULL },                    //                75
  313.             { NM_SUB, NULL,NULL,CHECKIT,~512,NULL },                //                76
  314.             { NM_SUB, NULL,NULL,CHECKIT,~1024,NULL },                    //                77
  315.             { NM_SUB, NULL,NULL,CHECKIT,~2048,NULL },                    //                78
  316.             { NM_SUB, NULL,NULL,CHECKIT,~4096,NULL },                //                79
  317.             { NM_SUB, NULL,NULL,CHECKIT,~8192,NULL },                //                80
  318.        { NM_ITEM,NULL, NULL, 0, NULL },                    //             81
  319.        { NM_ITEM,NULL, NULL, 0, NULL },                    //                82
  320.        { NM_ITEM,NULL,NULL,CHECKIT|MENUTOGGLE,NULL },        //                83
  321.        { NM_ITEM,NULL,NULL,CHECKIT|MENUTOGGLE,NULL },            //                84
  322.        { NM_ITEM,NM_BARLABEL,NULL,0,0,NULL },                                //             85
  323.         { NM_ITEM,NULL,NULL,0,NULL },                        //                86
  324.         { NM_ITEM,NULL,NULL,0,NULL },                                //                87
  325.         { NM_ITEM,NULL,NULL,0,NULL },                                    //                88
  326.       { NM_ITEM,NM_BARLABEL,NULL,0,0,NULL },                                    //             89
  327.     { NM_ITEM,NULL,NULL,CHECKIT|MENUTOGGLE,NULL },    //                90
  328.    { NM_END,NULL,NULL,0,0,NULL }
  329. };
  330.  
  331. /* Screen and VisualInfo for ControlWindow    */
  332. static struct Screen         *Screen    = NULL;
  333. static struct VisualInfo    *VisInfo    = NULL;
  334.  
  335. /* The Window and its menus and (animated) screen title    */
  336. extern struct Window            *ControlWindow    = NULL;
  337. extern struct Menu             *MyMenu             = NULL;
  338. extern UBYTE                    *CWTitle            = "                           ";    // note at least 3 spaces at end for frame number!
  339. //                                                          "TSMorph - Frame            "
  340.  
  341. /* Open the Control Window
  342.  * Not really sure why it returns a Struct Window *
  343.  * as ControlWindow is set up inside this function anyway
  344.  * should really be a BOOL
  345.  */
  346. struct Window *
  347. OpenControlWindow(void) {
  348.     ULONG HNum;            // The current edit mode is displayed as help
  349.     switch (Mode) {
  350.     case EDIT1:
  351.         HNum = H_EOne;
  352.         break;
  353.     case EDIT2:
  354.         HNum = H_ETwo;
  355.         break;
  356.     case EDITREL:
  357.         HNum = H_ERel;
  358.         break;
  359.     case ADD:
  360.         HNum = H_EAdd;
  361.         break;
  362.     case DELETE:
  363.         HNum = H_EDel;
  364.         break;
  365.     case LINK1:
  366.         HNum = H_ELnk;
  367.         break;
  368.     case UNLINK1:
  369.         HNum = H_EUnl;
  370.         break;
  371.     case NONE:
  372.         HNum = H_EMov;
  373.         break;
  374.     }
  375.     if (Screen = LockPubScreen(PubScreenName)) {        /* Supplied in PUBSCREEN=    */
  376.         // Dynamically position all the gadgets (actually only based on window top border)
  377.         /* Gadgets in the left column */
  378.         OneGadget.LeftEdge =
  379.             RelGadget.LeftEdge =
  380.             DelGadget.LeftEdge =
  381.             UnlinkGadget.LeftEdge =
  382.             stGadget.LeftEdge = Screen->WBorLeft; 
  383.         /* Gadgets in the right column */
  384.         TwoGadget.LeftEdge =
  385.             MyAddGadget.LeftEdge =
  386.             LinkGadget.LeftEdge =
  387.             NoneGadget.LeftEdge = Screen->WBorLeft + IMAGE_WIDTH;
  388.         prevGadget.LeftEdge = Screen->WBorLeft + AIMAGE;
  389.         gotoGadget.LeftEdge = Screen->WBorLeft + (AIMAGE+AIMAGE);
  390.         nextGadget.LeftEdge = Screen->WBorLeft + (AIMAGE+AIMAGE+AIMAGE+1);    // +1 as gotoGadget is 1 wider
  391.         lastGadget.LeftEdge = Screen->WBorLeft + (AIMAGE+AIMAGE+AIMAGE+1+AIMAGE);
  392.         /* Gadgets in top row */
  393.         OneGadget.TopEdge =
  394.             TwoGadget.TopEdge = Screen->WBorTop + Screen->Font->ta_YSize+1;
  395.         /* Gadgets in 2nd row */
  396.         RelGadget.TopEdge =
  397.             MyAddGadget.TopEdge = Screen->WBorTop + Screen->Font->ta_YSize+1+(IMAGE_HEIGHT);
  398.         /* Gadgets in 3rd row */
  399.         DelGadget.TopEdge =
  400.             LinkGadget.TopEdge = Screen->WBorTop + Screen->Font->ta_YSize+1+(IMAGE_HEIGHT+IMAGE_HEIGHT);
  401.         /* Gadgets in bottom (-1) row */
  402.         UnlinkGadget.TopEdge =
  403.             NoneGadget.TopEdge = Screen->WBorTop + Screen->Font->ta_YSize+1+(IMAGE_HEIGHT+IMAGE_HEIGHT+IMAGE_HEIGHT);
  404.         /* Arrow gadgets */
  405.         stGadget.TopEdge =
  406.             prevGadget.TopEdge =
  407.             gotoGadget.TopEdge =
  408.             nextGadget.TopEdge =
  409.             lastGadget.TopEdge = Screen->WBorTop + Screen->Font->ta_YSize+1+(IMAGE_HEIGHT+IMAGE_HEIGHT+IMAGE_HEIGHT+IMAGE_HEIGHT);
  410.         if ((SinglePicture == 2) || (SinglePicture == 3)) {        // Animated so set screen title
  411.             sprintf(CWTitle,MyGetMsg(MSG_TSMFRAME),FrameNumber);
  412.         }
  413.         else {
  414.             strcpy(CWTitle,MyGetMsg(MSG_TSM));                                        // Otherwise default
  415.         }
  416.         /* Open the window, in a default position */
  417.         if (ControlWindow = OpenWindowTags(NULL,
  418.                                         WA_Gadgets,         &OneGadget,
  419.                                         WA_IDCMP,            IDCMP_MENUPICK | IDCMP_CLOSEWINDOW | IDCMP_MENUHELP |
  420.                                                                 IDCMP_GADGETDOWN | IDCMP_RAWKEY | IDCMP_VANILLAKEY | IDCMP_GADGETUP |
  421.                                                                 IDCMP_GADGETHELP | IDCMP_MOUSEMOVE,
  422.                                         WA_SimpleRefresh, TRUE,
  423.                                         WA_Flags,            WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET |
  424.                                                                 WFLG_NOCAREREFRESH,
  425.                                         WA_PubScreen,         Screen,
  426.                                    WA_Width,            Screen->WBorLeft + Screen->WBorRight + 
  427.                                                                (IMAGE_WIDTH+IMAGE_WIDTH),
  428.                                    WA_Height,            Screen->WBorTop + Screen->Font->ta_YSize + 1 +
  429.                                                                Screen->WBorBottom +
  430.                                                                (IMAGE_HEIGHT+IMAGE_HEIGHT+IMAGE_HEIGHT+IMAGE_HEIGHT+AIMAGE),
  431.                                    WA_Left,                0,            // left edge of screen
  432.                                    WA_Top,                TSMorphWnd->TopEdge + Rect[GD_Help].MaxY + 2,
  433.                                         WA_ScreenTitle,    CWTitle,    //    Top edge means help gadget is still visible
  434.                                         WA_Title,            MyGetMsg(MSG_MOV),    // This is wrong - could be a different mode ?
  435.                                         WA_MenuHelp,        TRUE,
  436.                                         WA_NewLookMenus,    TRUE,
  437.                                         TAG_DONE)) {
  438.            if (IntuitionBase->LibNode.lib_Version > 38) {            // If running 3.0+ turn on gadget help
  439.                 HelpControl(ControlWindow,HC_GADGETHELP);
  440.             }
  441.             UpdateMenuDefs();                                        // Update the menu off/on/checks etc.
  442.          /* Create,layout and add the menu    */
  443.             if (MyMenu = CreateMenus(MyNewMenu,
  444.                                         GTMN_FullMenu,TRUE,
  445.                                         TAG_END)) {
  446.                 if (VisInfo = GetVisualInfo(Screen, TAG_END)) {
  447.                     if (LayoutMenus(MyMenu,VisInfo,
  448.                                             GTMN_NewLookMenus,TRUE,
  449.                                             TAG_END)) {
  450.                         if (SetMenuStrip(ControlWindow,MyMenu)) {
  451.                             // display either full or short help
  452.                             if (GHelp) {
  453.                                 help(HNum);
  454.                             }
  455.                             else {
  456.                                 ihelp(HNum);
  457.                             }
  458.                             MySetMode(Mode);
  459.                             return ControlWindow;        /* Success !!!                        */
  460.                         }
  461.                     }
  462.                 }
  463.             }
  464.         }
  465.     }
  466.     /* Something failed so clear everything down    */
  467.     CloseControlWindow();
  468.     return NULL;
  469. }
  470.         
  471.  
  472. /* Close the Control Window
  473.  * or at least as much as it is open
  474.  * Clearing down all variables
  475.  */
  476. void
  477. CloseControlWindow(void) {
  478.     if (ControlWindow) {
  479.         ClearMenuStrip(ControlWindow);
  480.     }
  481.     if (VisInfo) {
  482.         FreeVisualInfo(VisInfo);
  483.         VisInfo = NULL;
  484.     }
  485.     if (MyMenu) {
  486.         FreeMenus(MyMenu);
  487.         MyMenu = NULL;
  488.     }
  489.     if (ControlWindow) {
  490.         CloseWindow(ControlWindow);
  491.         ControlWindow = NULL;
  492.     }
  493.     if (Screen) {
  494.         UnlockPubScreen(NULL,Screen);
  495.         Screen = NULL;
  496.     }
  497. }
  498.  
  499. /* Update the new menu array based on the current settings
  500.  * updates enabled/disabled status
  501.  * and checkmarks
  502.  */
  503. void
  504. UpdateMenuDefs(void) {
  505.     if ((SinglePicture == 2) || (SinglePicture == 3)) {    // No frame controls if not anim
  506.       MyNewMenu[NM_FRAME].nm_Flags &= ~NM_ITEMDISABLED;
  507.     }
  508.     else {
  509.       MyNewMenu[NM_FRAME].nm_Flags |= NM_ITEMDISABLED;
  510.     }
  511.    if (CreateIcons) {                            /* Supplied in CREATEICONS=    */
  512.       MyNewMenu[NM_CREATEICONS].nm_Flags |= CHECKED;
  513.    }
  514.    else {
  515.       MyNewMenu[NM_CREATEICONS].nm_Flags &= ~CHECKED;
  516.    }
  517.    if (CreateIconsP) {                            /* Supplied in CREATEICONSP=    */
  518.       MyNewMenu[NM_ICONSP].nm_Flags |= CHECKED;
  519.    }
  520.    else {
  521.       MyNewMenu[NM_ICONSP].nm_Flags &= ~CHECKED;
  522.    }
  523.    if (KeepSettings) {                            /* Supplied in KEEPSETTINGS=    */
  524.       MyNewMenu[NM_KEEPS].nm_Flags |= CHECKED;
  525.    }
  526.    else {
  527.       MyNewMenu[NM_KEEPS].nm_Flags &= ~CHECKED;
  528.    }
  529.     if (PaletteAllowed) {                        /* Supplied in CHANGEPALETTE=    */
  530.       MyNewMenu[NM_CHANGEPALETTE].nm_Flags &= ~NM_ITEMDISABLED;
  531.     }
  532.     else {
  533.       MyNewMenu[NM_CHANGEPALETTE].nm_Flags |= NM_ITEMDISABLED;
  534.     }
  535.    if (palette) {                                    /* Supplied in CHANGEPALETTE=    */
  536.       MyNewMenu[NM_CHANGEPALETTE].nm_Flags |= CHECKED;
  537.    }
  538.    else {
  539.       MyNewMenu[NM_CHANGEPALETTE].nm_Flags &= ~CHECKED;
  540.    }
  541.     if (ZoomAllowed) {                            /* Supplied in ZOOM=                */
  542.       MyNewMenu[NM_ZOOM].nm_Flags &= ~NM_ITEMDISABLED;
  543.     }
  544.     else {
  545.       MyNewMenu[NM_ZOOM].nm_Flags |= NM_ITEMDISABLED;
  546.     }
  547.    if (Zoom) {                                        /* Supplied in ZOOM=                */
  548.       MyNewMenu[NM_ZOOM].nm_Flags |= CHECKED;
  549.    }
  550.    else {
  551.       MyNewMenu[NM_ZOOM].nm_Flags &= ~CHECKED;
  552.    }
  553.    if (AntiAlias) {                                /* Supplied in ANTIALIAS=        */
  554.       MyNewMenu[NM_ANTIALIAS].nm_Flags |= CHECKED;
  555.    }
  556.    else {
  557.       MyNewMenu[NM_ANTIALIAS].nm_Flags &= ~CHECKED;
  558.    }
  559.    if (Integer) {                                    /* Supplied in INTEGER=            */
  560.       MyNewMenu[NM_INTEGER].nm_Flags |= CHECKED;
  561.    }
  562.    else {
  563.       MyNewMenu[NM_INTEGER].nm_Flags &= ~CHECKED;
  564.    }
  565.    if (!ReqToolsBase) {                            // No reqtools.library so disable all string and int requesters
  566.        MyNewMenu[NM_SCREEN].nm_Flags |= NM_ITEMDISABLED;
  567.        MyNewMenu[NM_DX].nm_Flags |= NM_ITEMDISABLED;
  568.        MyNewMenu[NM_DY].nm_Flags |= NM_ITEMDISABLED;
  569.        MyNewMenu[NM_LOADSCRIPT].nm_Flags |= NM_ITEMDISABLED;
  570.        MyNewMenu[NM_PRESCRIPT].nm_Flags |= NM_ITEMDISABLED;
  571.        MyNewMenu[NM_POSTSCRIPT].nm_Flags |= NM_ITEMDISABLED;
  572.        MyNewMenu[NM_DEPTH].nm_Flags |= NM_ITEMDISABLED;
  573.        MyNewMenu[NM_QUALITY].nm_Flags |= NM_ITEMDISABLED;
  574.        MyNewMenu[NM_SCREENR].nm_Flags |= NM_ITEMDISABLED;
  575.        MyNewMenu[NM_PPREVIEW].nm_Flags |= NM_ITEMDISABLED;
  576.        MyNewMenu[NM_SPREVIEW].nm_Flags |= NM_ITEMDISABLED;
  577.        MyNewMenu[NM_CUSTOM].nm_Flags |= NM_ITEMDISABLED;
  578.        MyNewMenu[NM_CDEPTH].nm_Flags |= NM_ITEMDISABLED;
  579.        TSMorphNewMenu[12].nm_Flags |= NM_ITEMDISABLED;
  580.    }
  581.    if (!OpalBase) {                                // No opal.library so disable opal output formats and input mode
  582.        MyNewMenu[NM_OPAL24].nm_Flags |= NM_ITEMDISABLED;
  583.        MyNewMenu[NM_OPAL24T].nm_Flags |= NM_ITEMDISABLED;
  584.        MyNewMenu[NM_OPAL24F].nm_Flags |= NM_ITEMDISABLED;
  585.        MyNewMenu[NM_OPAL24FT].nm_Flags |= NM_ITEMDISABLED;
  586.        MyNewMenu[NM_OPALJPEG].nm_Flags |= NM_ITEMDISABLED;
  587.        MyNewMenu[NM_OPALJPEGT].nm_Flags |= NM_ITEMDISABLED;
  588.        MyNewMenu[NM_QUALITY].nm_Flags |= NM_ITEMDISABLED;
  589.        MyNewMenu[NM_ILBMOPAL].nm_Flags |= NM_ITEMDISABLED;
  590.    }
  591.    if (!DCTVBase) {                                // no dctv.library so disable dctv output formats
  592.        MyNewMenu[NM_DCTV3].nm_Flags |= NM_ITEMDISABLED;
  593.        MyNewMenu[NM_DCTV4].nm_Flags |= NM_ITEMDISABLED;
  594.    }
  595.    if (CreateIconsR) {                            /* Supplied in CREATEICONSR=    */
  596.       MyNewMenu[NM_ICONSR].nm_Flags |= CHECKED;
  597.    }
  598.    else {
  599.       MyNewMenu[NM_ICONSR].nm_Flags &= ~CHECKED;
  600.    }
  601.    if (GHelp) {                                    /* Supplied in HELP=                */
  602.       MyNewMenu[NM_HELP].nm_Flags |= CHECKED;
  603.    }
  604.    else {
  605.       MyNewMenu[NM_HELP].nm_Flags &= ~CHECKED;
  606.    }
  607.    if (!handle) {                                    // Have not managed to open amigaguide help file
  608.        MyNewMenu[NM_HELP].nm_Flags |= NM_ITEMDISABLED;
  609.    }
  610.    // Switch off all modes except current
  611.     MyNewMenu[NM_MODE1].nm_Flags &= ~CHECKED;
  612.     MyNewMenu[NM_MODE2].nm_Flags &= ~CHECKED;
  613.     MyNewMenu[NM_MODE4].nm_Flags &= ~CHECKED;
  614.     MyNewMenu[NM_MODE8].nm_Flags &= ~CHECKED;
  615.     MyNewMenu[NM_MODE16].nm_Flags &= ~CHECKED;
  616.     if (RenderMode & 1) {
  617.         MyNewMenu[NM_MODE1].nm_Flags |= CHECKED;
  618.     }
  619.     if (RenderMode & 2) {
  620.         MyNewMenu[NM_MODE2].nm_Flags |= CHECKED;
  621.     }
  622.     if (RenderMode & 4) {
  623.         MyNewMenu[NM_MODE4].nm_Flags |= CHECKED;
  624.     }
  625.     if (RenderMode & 8) {
  626.         MyNewMenu[NM_MODE8].nm_Flags |= CHECKED;
  627.     }
  628.     if (RenderMode & 16) {
  629.         MyNewMenu[NM_MODE16].nm_Flags |= CHECKED;
  630.     }
  631.     // switch off all output formats except current
  632.     MyNewMenu[NM_ILBM24].nm_Flags &= ~CHECKED;
  633.     MyNewMenu[NM_OPAL24].nm_Flags &= ~CHECKED;
  634.     MyNewMenu[NM_OPAL24T].nm_Flags &= ~CHECKED;
  635.     MyNewMenu[NM_OPAL24F].nm_Flags &= ~CHECKED;
  636.     MyNewMenu[NM_OPAL24FT].nm_Flags &= ~CHECKED;
  637.     MyNewMenu[NM_OPALJPEG].nm_Flags &= ~CHECKED;
  638.     MyNewMenu[NM_OPALJPEGT].nm_Flags &= ~CHECKED;
  639.     MyNewMenu[NM_PBM].nm_Flags &= ~CHECKED;
  640.     MyNewMenu[NM_BW16].nm_Flags &= ~CHECKED;
  641.     MyNewMenu[NM_BW256].nm_Flags &= ~CHECKED;
  642.     MyNewMenu[NM_HAM6].nm_Flags &= ~CHECKED;
  643.     MyNewMenu[NM_HAM8].nm_Flags &= ~CHECKED;
  644.     MyNewMenu[NM_DCTV3].nm_Flags &= ~CHECKED;
  645.     MyNewMenu[NM_DCTV4].nm_Flags &= ~CHECKED;
  646.     MyNewMenu[NM_ILBM24+SaveFormat].nm_Flags |= CHECKED;
  647.     // switch off all input modes except current
  648.     MyNewMenu[NM_ILBMALWAYS].nm_Flags &= ~CHECKED;
  649.     MyNewMenu[NM_ILBMIFILBM].nm_Flags &= ~CHECKED;
  650.     MyNewMenu[NM_ILBMIFCOLOURS].nm_Flags &= ~CHECKED;
  651.     MyNewMenu[NM_ILBMOPAL].nm_Flags &= ~CHECKED;
  652.     MyNewMenu[NM_ILBMALWAYS+OpenMode].nm_Flags |= CHECKED;
  653. }
  654.